/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.marcelo.agro.core;

import java.util.Collection;
import java.util.Collections;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;

/**
 *
 * @author marcelo
 */
public class DynamicLookup extends AbstractLookup{
    private static DynamicLookup lookup ;
    private InstanceContent content = null;
    
    public void add(Object inst) {
       content.add(inst);
    }
    
    public void remove(Object inst) {
        content.remove(inst);
    }
    
    private DynamicLookup(){
        this(new InstanceContent());
        
    }
    
    private DynamicLookup(InstanceContent content){
       super(content);
       this.content = content;
    }
    
    public static DynamicLookup getDefault(){
        if (lookup == null)
            lookup = new DynamicLookup();
        return lookup;
    }
    
    public void setSingleton(Object obj) {
       content.set(Collections.singleton(obj), null);
    }

    
    
    
}
